<template>
	<view class="member-container">
		<!-- 顶部导航栏 -->
		<view class="navbar">
			<view class="navbar-left" @click="goBack">
				<u-icon name="arrow-left" size="20" color="#fff"></u-icon>
			</view>
			<view class="navbar-title">会员中心</view>
			<view class="navbar-right">
				<view class="action-icon">
					<u-icon name="more-dot-fill" size="20" color="#fff"></u-icon>
				</view>
				<view class="action-icon">
					<u-icon name="minus" size="20" color="#fff"></u-icon>
				</view>
				<view class="action-icon">
					<u-icon name="setting" size="20" color="#fff"></u-icon>
				</view>
			</view>
		</view>

		<!-- 会员卡片滑动区域 -->
		<view class="membership-section">
			<scroll-view class="membership-scroll" scroll-x="true" show-scrollbar="false">
				<view class="membership-cards">
					<!-- 银卡会员 -->
					<view class="membership-card silver active">
						<view class="card-content">
							<view class="card-left">
								<text class="level-label">当前等级</text>
								<text class="level-name">银卡会员</text>
								<text class="growth-value">当前成长值0</text>
								<view class="progress-section">
									<view class="progress-bar">
										<view class="progress-fill" :style="{width: '0%'}"></view>
									</view>
									<text class="progress-text">0/20 还需20成长值,可升级金卡会员</text>
								</view>
							</view>
							<view class="card-right">
								<view class="level-icon silver-icon">
									<u-icon name="star" size="30" color="#fff"></u-icon>
								</view>
							</view>
						</view>
					</view>

					<!-- 金卡会员 -->
					<view class="membership-card gold">
						<view class="card-content">
							<view class="card-left">
								<text class="level-label">下一等级</text>
								<text class="level-name">金卡会员</text>
								<text class="growth-value">需要成长值20</text>
								<view class="progress-section">
									<view class="progress-bar">
										<view class="progress-fill" :style="{width: '0%'}"></view>
									</view>
									<text class="progress-text">0/50 还需50成长值,可升级钻石会员</text>
								</view>
							</view>
							<view class="card-right">
								<view class="level-icon gold-icon">
									<u-icon name="star" size="30" color="#fff"></u-icon>
								</view>
							</view>
						</view>
					</view>

					<!-- 钻石会员 -->
					<view class="membership-card diamond">
						<view class="card-content">
							<view class="card-left">
								<text class="level-label">最高等级</text>
								<text class="level-name">钻石会员</text>
								<text class="growth-value">需要成长值70</text>
								<view class="progress-section">
									<view class="progress-bar">
										<view class="progress-fill" :style="{width: '0%'}"></view>
									</view>
									<text class="progress-text">已到达最高等级</text>
								</view>
							</view>
							<view class="card-right">
								<view class="level-icon diamond-icon">
									<u-icon name="star" size="30" color="#fff"></u-icon>
								</view>
							</view>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>

		<!-- 会员权益摘要 -->
		<view class="benefits-summary">
			<text class="benefits-text">银卡会员享0项权益</text>
		</view>

		<!-- 积分任务 -->
		<view class="tasks-section">
			<view class="section-header">
				<view class="section-indicator"></view>
				<text class="section-title">积分任务</text>
			</view>
			<view class="task-list">
				<view class="task-item">
					<view class="task-left">
						<view class="task-icon">
							<img style="width: 50rpx; height: 50rpx;" src="/static/member/注册.png" alt="">
						</view>
						<view class="task-content">
							<view class="task-title">
								<text class="task-name">注册新用户</text>
								<text class="task-points">+10</text>
								<u-icon name="star" size="16" color="#ffd700"></u-icon>
							</view>
							<text class="task-desc">每位用户注册成为新会员可获得10积分</text>
						</view>
					</view>
					<view class="task-right">
						<u-button 
							type="default" 
							text="已完成" 
							size="mini"
							:custom-style="completedButtonStyle"
						></u-button>
					</view>
				</view>

				<view class="task-item">
					<view class="task-left">
						<view class="task-icon">
							<u-icon name="shopping-cart" size="24" color="#ff6b35"></u-icon>
						</view>
						<view class="task-content">
							<view class="task-title">
								<text class="task-name">商城购物</text>
								<text class="task-points">+1</text>
								<u-icon name="star" size="16" color="#ffd700"></u-icon>
							</view>
							<text class="task-desc">消费满10元,可获得1积分</text>
						</view>
					</view>
					<view class="task-right">
						<u-button 
							type="warning" 
							text="去完成" 
							size="mini"
							@click="goShopping"
							:custom-style="goButtonStyle"
						></u-button>
					</view>
				</view>
			</view>
		</view>

		<!-- 积分商城 -->
		<view class="points-mall-section">
			<view class="section-header">
				<view class="section-indicator"></view>
				<text class="section-title">积分商城</text>
				<text class="current-points">当前15积分</text>
			</view>
			<scroll-view class="products-scroll" scroll-x="true" show-scrollbar="false">
				<view class="products-list">
					<view class="product-item" @click="viewProduct('xiaol')">
						<view class="product-image">
							<view class="image-placeholder red-cube">
								<view class="cube-pattern">
									<img src="" alt="" />
								</view>
							</view>
						</view>
						<text class="product-name">xiaol</text>
					</view>

					<view class="product-item" @click="viewProduct('perfume')">
						<view class="product-image">
							<view class="image-placeholder perfume-bottle">
								<img src="" alt="" />
							</view>
						</view>
						<text class="product-name">先锋男士小样试用装</text>
					</view>

					<view class="product-item" @click="viewProduct('gift')">
						<view class="product-image">
							<view class="image-placeholder gift-box">
								<img src="" alt="" />
							</view>
						</view>
						<text class="product-name">精美礼品盒</text>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			completedButtonStyle: {
				backgroundColor: '#f0f0f0',
				color: '#999',
				borderRadius: '20rpx',
				height: '50rpx',
				fontSize: '22rpx',
				border: 'none'
			},
			goButtonStyle: {
				backgroundColor: '#ff6b35',
				color: '#fff',
				borderRadius: '20rpx',
				height: '50rpx',
				fontSize: '22rpx',
				border: 'none'
			}
		}
	},
	methods: {
		// 返回上一页
		goBack() {
			uni.navigateBack()
		},
		
		// 去购物
		goShopping() {
			uni.showToast({
				title: '跳转到商城',
				icon: 'none'
			})
		},
		
		// 查看商品
		viewProduct(productId) {
			uni.showToast({
				title: `查看商品: ${productId}`,
				icon: 'none'
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.member-container {
	min-height: 100vh;
	background-color: #1a1a1a;
	position: relative;
}

.navbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20rpx 30rpx;
	background-color: transparent;
	
	.navbar-left {
		width: 40rpx;
		height: 40rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	
	.navbar-title {
		font-size: 36rpx;
		font-weight: 600;
		color: #fff;
	}
	
	.navbar-right {
		display: flex;
		gap: 20rpx;
		
		.action-icon {
			width: 40rpx;
			height: 40rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
}

.membership-section {
	padding: 30rpx 0;
	
	.membership-scroll {
		white-space: nowrap;
		
		.membership-cards {
			display: flex;
			padding: 0 30rpx;
			gap: 20rpx;
			
			.membership-card {
				min-width: 600rpx;
				height: 300rpx;
				border-radius: 20rpx;
				padding: 30rpx;
				position: relative;
				overflow: hidden;
				
				&.silver {
					background: linear-gradient(135deg, #b8c6db 0%, #f5f7fa 100%);
					
					&.active {
						transform: scale(1.05);
						box-shadow: 0 10rpx 30rpx rgba(184, 198, 219, 0.3);
					}
					
					.silver-icon {
						background: linear-gradient(135deg, #c0c0c0 0%, #e5e4e2 100%);
					}
				}
				
				&.gold {
					background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
					
					.gold-icon {
						background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
					}
				}
				
				&.diamond {
					background: linear-gradient(135deg, #b9f2ff 0%, #e0f6ff 100%);
					
					.diamond-icon {
						background: linear-gradient(135deg, #b9f2ff 0%, #e0f6ff 100%);
					}
				}
				
				.card-content {
					display: flex;
					justify-content: space-between;
					align-items: flex-start;
					height: 100%;
					
					.card-left {
						flex: 1;
						display: flex;
						flex-direction: column;
						
						.level-label {
							font-size: 24rpx;
							color: #666;
							margin-bottom: 10rpx;
						}
						
						.level-name {
							font-size: 40rpx;
							font-weight: 600;
							color: #333;
							margin-bottom: 10rpx;
						}
						
						.growth-value {
							font-size: 26rpx;
							color: #666;
							margin-bottom: 20rpx;
						}
						
						.progress-section {
							.progress-bar {
								width: 100%;
								height: 8rpx;
								background-color: rgba(0, 0, 0, 0.1);
								border-radius: 4rpx;
								margin-bottom: 10rpx;
								overflow: hidden;
								
								.progress-fill {
									height: 100%;
									background: linear-gradient(90deg, #ff6b35 0%, #ff8c42 100%);
									border-radius: 4rpx;
									transition: width 0.3s ease;
								}
							}
							
							.progress-text {
								font-size: 22rpx;
								color: #666;
								line-height: 1.4;
							}
						}
					}
					
					.card-right {
						.level-icon {
							width: 80rpx;
							height: 80rpx;
							border-radius: 50%;
							display: flex;
							align-items: center;
							justify-content: center;
							box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
						}
					}
				}
			}
		}
	}
}

.benefits-summary {
	padding: 0 30rpx 30rpx;
	
	.benefits-text {
		font-size: 28rpx;
		color: #fff;
		opacity: 0.8;
	}
}

.tasks-section, .points-mall-section {
	background-color: #fff;
	margin: 0 20rpx 20rpx;
	border-radius: 16rpx;
	padding: 30rpx;
	
	.section-header {
		display: flex;
		align-items: center;
		margin-bottom: 30rpx;
		
		.section-indicator {
			width: 6rpx;
			height: 30rpx;
			background: linear-gradient(135deg, #ff6b35 0%, #ff8c42 100%);
			border-radius: 3rpx;
			margin-right: 16rpx;
		}
		
		.section-title {
			font-size: 32rpx;
			font-weight: 600;
			color: #333;
			flex: 1;
		}
		
		.current-points {
			font-size: 26rpx;
			color: #ff6b35;
			font-weight: 500;
		}
	}
}

.task-list {
	.task-item {
		display: flex;
		align-items: center;
		padding: 20rpx 0;
		
		&:first-child {
			border-bottom: 1rpx solid #f0f0f0;
		}
		
		.task-left {
			display: flex;
			align-items: center;
			flex: 1;
			
			.task-icon {
				width: 60rpx;
				height: 60rpx;
				background-color: #fff5f5;
				border-radius: 50%;
				display: flex;
				align-items: center;
				justify-content: center;
				margin-right: 20rpx;
			}
			
			.task-content {
				flex: 1;
				
				.task-title {
					display: flex;
					align-items: center;
					margin-bottom: 8rpx;
					
					.task-name {
						font-size: 28rpx;
						font-weight: 500;
						color: #333;
						margin-right: 10rpx;
					}
					
					.task-points {
						font-size: 24rpx;
						color: #ff6b35;
						font-weight: 600;
						margin-right: 8rpx;
					}
				}
				
				.task-desc {
					font-size: 24rpx;
					color: #999;
					line-height: 1.4;
				}
			}
		}
		
		.task-right {
			margin-left: 20rpx;
		}
	}
}

.products-scroll {
	white-space: nowrap;
	
	.products-list {
		display: flex;
		gap: 20rpx;
		
		.product-item {
			min-width: 200rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			
			.product-image {
				margin-bottom: 16rpx;
				
				.image-placeholder {
					width: 160rpx;
					height: 160rpx;
					border-radius: 12rpx;
					position: relative;
					display: flex;
					align-items: center;
					justify-content: center;
					
					&.red-cube {
						background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
						
						.cube-pattern {
							position: relative;
							width: 80rpx;
							height: 80rpx;
							
							.pattern-star {
								position: absolute;
								top: 10rpx;
								left: 20rpx;
								width: 20rpx;
								height: 20rpx;
								background-color: #fff;
								clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
							}
							
							.pattern-circle {
								position: absolute;
								top: 30rpx;
								right: 10rpx;
								width: 16rpx;
								height: 16rpx;
								background-color: #fff;
								border-radius: 50%;
							}
							
							.pattern-triangle {
								position: absolute;
								bottom: 10rpx;
								left: 30rpx;
								width: 0;
								height: 0;
								border-left: 12rpx solid transparent;
								border-right: 12rpx solid transparent;
								border-bottom: 20rpx solid #fff;
							}
						}
					}
					
					&.perfume-bottle {
						background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
						
						.bottle-body {
							width: 60rpx;
							height: 80rpx;
							background-color: rgba(255, 255, 255, 0.2);
							border-radius: 30rpx 30rpx 10rpx 10rpx;
							position: relative;
						}
						
						.bottle-cap {
							position: absolute;
							top: -15rpx;
							left: 50%;
							transform: translateX(-50%);
							width: 30rpx;
							height: 20rpx;
							background-color: #ccc;
							border-radius: 15rpx 15rpx 5rpx 5rpx;
						}
						
						.bottle-band {
							position: absolute;
							top: 20rpx;
							left: 50%;
							transform: translateX(-50%);
							width: 40rpx;
							height: 8rpx;
							background-color: #ccc;
							border-radius: 4rpx;
						}
					}
					
					&.gift-box {
						background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%);
						
						.box-body {
							width: 80rpx;
							height: 60rpx;
							background-color: rgba(255, 255, 255, 0.2);
							border-radius: 8rpx;
							position: relative;
						}
						
						.box-ribbon {
							position: absolute;
							top: 50%;
							left: 50%;
							transform: translate(-50%, -50%);
							width: 4rpx;
							height: 50rpx;
							background-color: #fff;
							border-radius: 2rpx;
							
							&::before {
								content: '';
								position: absolute;
								top: 50%;
								left: 50%;
								transform: translate(-50%, -50%);
								width: 30rpx;
								height: 4rpx;
								background-color: #fff;
								border-radius: 2rpx;
							}
						}
					}
				}
			}
			
			.product-name {
				font-size: 24rpx;
				color: #333;
				text-align: center;
				line-height: 1.3;
			}
		}
	}
}
</style> 